package edu.zzu.daoImpl;

import edu.zzu.Entity.User;
import edu.zzu.dao.UserDao;
import edu.zzu.mapper.PackageMapper;
import edu.zzu.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserDaoImpl implements UserDao {
    @Autowired
    private UserMapper mapper;

    @Override
    public boolean checkIfUserExistById(Long userId) {
        return mapper.existsWithPrimaryKey(userId);
    }

    @Override
    public String getPasswordById(Long userId) {
        return mapper.getPasswordById(userId);
    }

    @Override
    public String getPasswordByTel(String tel) {
        return mapper.getPasswordByTel(tel);
    }

    @Override
    public int saveUser(User user) {
        return mapper.saveUser(user);
    }

    @Override
    public boolean checkIfUserExistByTel(String tel) {
        return mapper.checkIfUserExistByTel(tel) == 1;
    }

    @Override
    public Long getIdByTel(String tel) {
        return null;
    }

    @Override
    public int modifyPassword(Long id, String pwd) {
        return mapper.modifyPassword(id,pwd);
    }

    @Override
    public User selectUserByTel(String tel) {
        return mapper.selectUserByTel(tel);
    }

    @Override
    public Boolean isSourceNodeHasUser(Long sourceNode) {
        return mapper.selectCountBySourceNode(sourceNode)>0;
    }
}
